package ynu.lcy.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Where;
import ynu.lcy.elememicroservicecommon.entity.LogicEntity;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;

/*
* 购物车项，作为中间实体，分别指向所属购物车以及所属商品
* */
@Entity
@Setter
@Getter
@NoArgsConstructor
@Where(clause = "is_deleted = 0 and quantity> 0")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
public class CartFoodItem extends LogicEntity {
    /*
     * 数量
     * */
    private Integer quantity;

    @ManyToOne(fetch = FetchType.EAGER)
    @JsonIgnoreProperties(value = {"cartItems"})
    private Cart cart;

    @ManyToOne(fetch = FetchType.EAGER)
    @JsonIgnoreProperties(value = {"cartItems"})
    private Food food;
}
